package 算法;
//https://leetcode-cn.com/problems/search-a-2d-matrix-ii/
public class 搜索二维矩阵 {
    public static void main(String[] args) {
        System.out.println(searchMatrix(new int[][]{{-5}},7));
    }
    public static boolean searchMatrix(int[][] matrix, int target) {
        if(matrix.length == 0) return false;
        int x,y;
        x = matrix.length-1;
        y=0;
        int i = matrix[0].length;
        while (x > 0 && y < i){
            if(matrix[x][y] == target) return true;
            else if(matrix[x][y] > target) x--;
            else y++;
        }
        return false;
    }
}
